﻿using Lists;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Users;
using Sim;
using ClientApplication;

namespace Sim
{
    public class PresenterMain
    {
        public IMain _view { get; set; }
        public ITournament _modelTournament { get; set; }
        public ITournamentList _modelTournamentList { get; set; }
        public ILogin _modelLogin { get; set; }
        public IUserList _modelUserList { get; set; }

        public PresenterMain(IMain view, Login login, UserList ul, TournamentList tl)
        {
            this._modelLogin = login;
            this._modelUserList = ul;
            this._modelTournamentList = tl;
            this._view = view;
            this._view.EventLogin += NewLogin;
            this._view.EventOpenSignUpWindow += NewSignUpWindow;
            this._view.EventNewTournament += NewTournament;
            this._view.EventRefreshTournamentList += RefreshList;
            this._view.EventRefreshUserList += RefreshUserList;
            this._view.EventApplyForTournament += ApplyForTournament;
            this._view.EventAcceptUserForTournament += AcceptUserForTournament;
            this._view.EventDeclineUserForTournament += DeclineUserForTournament;
            this._view.EventRemoveTournament += RemoveTournament;
            this._view.EventStartTournament += StartTournament;
            this._view.EventAddJudgeToTournament += AddJudgeToTournament;
            this._view.EventSubmitDive += SubmitDive;
            this._view.EventSubmitJudgeScore += SubmitJudgeScore;
            //this._view.EventSignUp += NewSignUp;
        }

        public void SubmitJudgeScore(string username, string tournamentName, string divecode, string score, string round, string judgeusername)
        {
            Program.ca.SubmitJudgeScore(username, tournamentName, divecode, score, round, judgeusername);
        }

        public void SubmitDive(List<string> dives, string username, string tournamentName)
        {
            Program.ca.SubmitDive(dives, username, tournamentName);
        }

        public void AddJudgeToTournament(string username, string tournamentName)
        {
            Program.ca.AddJudgeToTournament(username, tournamentName);
        }
        public void StartTournament(string tournamentName)
        {
            Program.ca.StartTournament(tournamentName);
        }

        public void RemoveTournament(string tournamentName)
        {
            Program.ca.RemoveTournament(tournamentName);
        }

        public void DeclineUserForTournament(string username, string tournamentName)
        {
            Program.ca.sendDeclineApplication(username, tournamentName);
        }

        public void AcceptUserForTournament(string username, string tournamentName)
        {
            Program.ca.sendConfirmApplication(username, tournamentName);
        }

        public void ApplyForTournament(string tournamentName)
        {
            Program.ca.sendApplication(tournamentName);
        }

        public void NewLogin(string username, string password)
        {
            Program.ca.sendLogin(username, password);
        }

        public void RefreshList() //string parameter
        {
            Program.ca.sendRefreshRequest();
        }

        public void RefreshUserList()
        {
            Program.ca.sendRefreshRequestUser();
        }
        //public int NewSignUp(User u)
        //{
        //    return this._modelUserList.AddUser(u);
        //}

        public void NewTournament(Tournament t)
        {
            Program.ca.createTournament(t);
        }

        public void NewSignUpWindow() //Multipla instanser
        {
            SignUp su = new SignUp();
            PresenterSignUp presenter2 = new PresenterSignUp(su, Program.ul);
            su.Show();
        }
    }
}
